fix(msi): do not completely remove the previous installation when updating
authorJyrki Gadinger <nilsding@nilsding.org>
Wed, 7 May 2025 14:07:37 +0000 (16:07 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 30 May 2025 07:40:29 +0000 (09:40 +0200)
The MSIs we distribute perform so-called "major upgrades".

From the Microsoft docs, we learn that...

> A typical major upgrade **removes a previous version** of an
> application and installs a new version.

Indeed that was the case -- the previous version is uninstalled
completely before the new version gets installed.  Since we install an
extension that's loaded by explorer, the installer will ask the user to
restart Windows Explorer during the uninstallation of the previous
version (and restarting that might not always work as expected).

There is a way to change this behaviour though, using Wix3's
`MajorUpgrade` element.  Through its `Schedule` property it's possible
to define when the removal of the previous version should occur.

The previous value `afterInstallInitialize` is one of two values that
perform a complete uninstall/install sequence.  The new value
`afterInstallExecute` will install new files on top of the previous
installation (depending on the `REINSTALLMODE` I guess) and remove
older files that are not present.
In the case of the extensions this means that the .dlls from the
previous installation will not be touched, as long as the version
embedded in the DLL info didn't change.  This results in the installer
no longer requesting Windows Explorer to restart, which is a big plus :D

I also changed the REINSTALLMODE to `dmus` to allow downgrades as well.

With this change, the request to restart Windows Explorer should
hopefully happen only once an installation was made using an MSI that
contains this change.  Further updates will only request a restart if
the DLL version of these extensions change...

See also:
  - https://learn.microsoft.com/en-us/windows/win32/msi/major-upgrades
  - https://docs.firegiant.com/wix/schema/wxs/majorupgrade/#attributes:~:text=Schedule

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
admin/win/msi/Nextcloud.wxs

index a655c74cfe75707d0edfa5ab946b71c2c8c0b6d5..3a9ddcdbee255b5dba637ea84948bdf72dd85274 100644 (file)
@@ -44,8 +44,8 @@
         https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/replacing-ourselves/
         https://www.joyofsetup.com/2010/01/16/major-upgrades-now-easier-than-ever/
     -->
-    <MajorUpgrade Schedule="afterInstallInitialize" AllowDowngrades="yes" />
-    <Property Id="REINSTALLMODE" Value="omus" />
+    <MajorUpgrade Schedule="afterInstallExecute" AllowDowngrades="yes" />
+    <Property Id="REINSTALLMODE" Value="dmus" />
 
     <Media Id="1" Cabinet="$(var.AppShortName).cab" EmbedCab="yes" />